Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support deployment freeze recurring schedule #840

Merged
merged 15 commits into from
Dec 17, 2024

Conversation

HuyPhanNguyen
Copy link
Collaborator

@HuyPhanNguyen HuyPhanNguyen commented Dec 8, 2024

  • Deployment freeze support recurring schedule
  • Deployment freeze data source support retrieves recurring schedule
  • Deployment freeze data source support retrieves tenant scopes
  • Add test for deployment freeze data source
  • Add validation for recurring schedule

sc-99172

resource "octopusdeploy_deployment_freeze" "test_freeze" {
    name  = "Test Recurring Freeze"
    start = "2025-12-09T01:47:00Z"
    end   = "2025-12-10T01:47:00Z"
    
    recurring_schedule = {
        type = "DaysPerWeek"
        unit = 24
        end_type = "AfterOccurrences"
        end_after_occurrences = 5
        days_of_week = ["Monday", "Wednesday", "Friday"]
    }

    # depends_on = [octopusdeploy_space.test_space]
}

Create

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # octopusdeploy_deployment_freeze.test_freeze will be created
  + resource "octopusdeploy_deployment_freeze" "test_freeze" {
      + end                = "2025-12-10T01:47:00Z"
      + id                 = (known after apply)
      + name               = "Test Recurring Freeze"
      + recurring_schedule = {
          + days_of_week          = [
              + "Monday",
              + "Wednesday",
              + "Friday",
            ]
          + end_after_occurrences = 5
          + end_type              = "AfterOccurrences"
          + type                  = "DaysPerWeek"
          + unit                  = 24
        }
      + start              = "2025-12-09T01:47:00Z"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

octopusdeploy_deployment_freeze.test_freeze: Creating...
octopusdeploy_deployment_freeze.test_freeze: Creation complete after 0s [id=DeploymentFreezes-814]

Update

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # octopusdeploy_deployment_freeze.test_freeze will be updated in-place
  ~ resource "octopusdeploy_deployment_freeze" "test_freeze" {
        id                 = "DeploymentFreezes-821"
        name               = "Test Recurring Freeze"
      ~ recurring_schedule = {
          ~ days_of_week          = [
              + "Sunday",
                "Monday",
              - "Wednesday",
                "Friday",
            ]
          ~ end_after_occurrences = 5 -> 15
            # (3 unchanged attributes hidden)
        }
        # (2 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

octopusdeploy_deployment_freeze.test_freeze: Modifying... [id=DeploymentFreezes-821]
octopusdeploy_deployment_freeze.test_freeze: Modifications complete after 0s [id=DeploymentFreezes-821]

Destroy

  # octopusdeploy_deployment_freeze.test_freeze will be destroyed
  # (because octopusdeploy_deployment_freeze.test_freeze is not in configuration)
  - resource "octopusdeploy_deployment_freeze" "test_freeze" {
      - end                = "2025-12-10T01:47:00Z" -> null
      - id                 = "DeploymentFreezes-821" -> null
      - name               = "Test Recurring Freeze" -> null
      - recurring_schedule = {
          - days_of_week          = [
              - "Sunday",
              - "Monday",
              - "Friday",
            ] -> null
          - end_after_occurrences = 15 -> null
          - end_type              = "AfterOccurrences" -> null
          - type                  = "DaysPerWeek" -> null
          - unit                  = 24 -> null
        } -> null
      - start              = "2025-12-09T01:47:00Z" -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

octopusdeploy_deployment_freeze.test_freeze: Destroying... [id=DeploymentFreezes-821]
octopusdeploy_deployment_freeze.test_freeze: Destruction complete after 0s

@HuyPhanNguyen HuyPhanNguyen changed the title Support deployment freeze recurring schedule feat: support deployment freeze recurring schedule Dec 9, 2024
Copy link
Collaborator

@benPearce1 benPearce1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good but adding validation would be ideal.
I got the following error when setting type to DaysPerMonth but not setting monthly_schedule_type:

Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to octopusdeploy_deployment_freeze.freeze, provider "provider[\"octopus.com/com/octopusdeploy\"]" produced an unexpected new value:
│ .recurring_schedule.monthly_schedule_type: was null, but now cty.StringVal("DateOfMonth").

domenicsim1
domenicsim1 previously approved these changes Dec 9, 2024
@domenicsim1 domenicsim1 dismissed their stale review December 9, 2024 07:58

Validation errors upon using it

Copy link
Contributor

@domenicsim1 domenicsim1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks, good to me

@HuyPhanNguyen HuyPhanNguyen merged commit 6643d95 into main Dec 17, 2024
23 checks passed
@HuyPhanNguyen HuyPhanNguyen deleted the huy/deployment-freeze-recurring branch December 17, 2024 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants